<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>七夕快乐</title>
		<style>
			*{
				padding: 0px;
				margin: 0px;
			}
			#tp{
				height:900px;
				margin: auto;
			}
			#txt{
				text-align: center;
				font-weight: bold;
				font-size:125px;
				line-height:900px;
			}
		</style>
	</head>
	<body>
		<div id="tp">
			<p id="txt">10</p>
		</div>

		<script>
			window.onload = function(){
				var otxt = document.getElementById("txt");
				var otp = document.getElementById("tp");
				var timer = null;
				var i = 9;
				
					if(timer){
						clearInterval(timer);
					}
					timer = setInterval(function(){
						if(i == -1){
							i = "七夕快乐";
							otp.style.backgroundImage = "url(img/9544bab6bbf06291006e500c1137c994.gif)";
							clearInterval(timer);
							setInterval(function(){
								otxt.style.color = vvv();
							},10)
						}
						otxt.innerHTML = i;
						i--;
					},1000)
					function vvv(){
                var r=Math.floor(Math.random()*256);
                var g=Math.floor(Math.random()*256);
                var b=Math.floor(Math.random()*256);
                //在控制器中显示出随机生成的颜色(可以删除,无影响)
                console.log("rgb("+r+","+g+","+b+")");
                //返回随机生成的颜色
                return "rgb("+r+","+g+","+b+")";
            }
			}
		</script>
	</body>
</html>
